package com.ticket.sass.admin.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ticket.sass.admin.mapper.MemberCardOrderRecordMapper;
import com.ticket.sass.admin.service.BaseService;
import com.ticket.sass.common.entity.tenant.MemberCardOrderRecordEntity;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 交易记录 服务实现类
 * </p>
 *
 * @author ywb
 * @since 2024-03-06
 */
@Service
public class MemberCardOrderRecordServiceImpl extends ServiceImpl<MemberCardOrderRecordMapper, MemberCardOrderRecordEntity> implements BaseService<MemberCardOrderRecordEntity> {
    public IPage<MemberCardOrderRecordEntity> getByCardIdWithPage(Long userId, Integer pageNum, Integer pageSize) {
        // 创建分页对象
        Page<MemberCardOrderRecordEntity> page = new Page<>(pageNum, pageSize);
        
        // 创建查询条件构造器
        QueryWrapper<MemberCardOrderRecordEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        queryWrapper.orderByDesc("id");
        // 执行查询
        return baseMapper.selectPage(page, queryWrapper);
    }
}
